package org.ling.xuan.dialog;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.Nullable;
import org.ling.xuan.dao.ProjectDao;
import org.ling.xuan.entity.mo.ProjectSetting;
import org.ling.xuan.pannel.ProjectSettingPanel;

import javax.swing.*;

public class ProjectSettingDialog extends DialogWrapper {
    private final ProjectSettingPanel mainPanel;

    public ProjectSettingDialog(@Nullable Project project, boolean canBeParent, String basePath) {
        super(project, canBeParent);
        setTitle("Setting Project");
        ProjectSetting setting = ProjectDao.getSetting(basePath);
        mainPanel = new ProjectSettingPanel(project, setting);
        init();
    }

    @Override
    protected @Nullable JComponent createCenterPanel() {
        return mainPanel;
    }

    public ProjectSetting getSetting() {
        return mainPanel.getSetting();
    }
}
